﻿namespace HuwmanCode.Transactions

open System
open System.Transactions
open HuwmanCode
open HuwmanCode.Transactions
open NUnit.Framework
open FsUnit

[<TestFixture>]
type ``Action ``() =
    [<Test>]
    member this.``Action.TryOnTransactionCommit``() =
        let actionInvoked = ref false

        let tran = new TransactionScope()
        Action.TryOnTransactionCommit(new Action(fun _ -> actionInvoked := true))
        tran.Complete()
        tran.Dispose()

        !actionInvoked |> should be True

    [<Test>]
    member this.``Action.TryOnTransactionRollback``() =
        let actionInvoked = ref false

        let tran = new TransactionScope()
        Action.TryOnTransactionRollback(new Action(fun _ -> actionInvoked := true))
        tran.Dispose()

        !actionInvoked |> should be True